# 构建阶段1
FROM registry.cn-hangzhou.aliyuncs.com/frank-public/centos:7.9.0-F1.2-jre-17 as Builder
MAINTAINER renjiangyang@vimicro.com

# 构建阶段1-定义构建变量
ARG jar=caesar-module-ai-openAi
ARG version
RUN echo "Building file:${jar}-1.0.0"
ADD target/${jar}-1.0.0-package.tar.gz /home

# 构建阶段2
FROM registry.cn-hangzhou.aliyuncs.com/frank-public/centos:7.9.0-F1.2-jre-17
MAINTAINER renjiangyang@vimicro.com

# 构建阶段2-定义构建变量
ARG jar=caesar-module-ai-openAi
ARG version
RUN echo "Building file:${jar}-1.0.0"

# 容器操作
WORKDIR /home
# 容器操作-构建目录
RUN echo 1.0.0 && mkdir -p /home/resources && mkdir -p /home/lib

COPY --from=builder /home/${jar}-1.0.0/resources               /home/resources
COPY --from=builder /home/${jar}-1.0.0/lib                     /home/lib
COPY --from=builder /home/${jar}-1.0.0/docker-entrypoint.sh    /home
COPY --from=builder /home/${jar}-1.0.0/${jar}-1.0.0.jar   /home/${jar}-1.0.0.jar
COPY --from=builder /home/${jar}-1.0.0/*.bat                   /home
COPY --from=builder /home/${jar}-1.0.0/*.sh                    /home

# 定义运行时参数,如 docker run --name OpenAi --env JAVA_OPTS="-Xms128M -Xmx512M" OpenAi:1.0.0
ENV JAVA_OPTS=""
# 定义运行时参数,如 docker run --name OpenAi --env JAVA_PARAMS="--spring.config.location=config/application.properties" OpenAi:1.0.0
ENV JAVA_PARM=""
# 其它环境变量
ENV TZ="Asia/Shanghai"

EXPOSE 9999/tcp
WORKDIR /home

ENTRYPOINT ["/home/docker-entrypoint.sh"]

# 构建
# docker build --no-cache --build-arg version=1.0.0 --progress=plain -t caesar-module-ai-openAi:1.0.0 .
#
# 运行
# docker run -d -p 28080:28080 --name caesar-module-ai-openAi-1.0.0 --env JAVA_OPTS="-Xms128M -Xmx512M" --env PARAMS="--spring.config.location=resources/application.properties" -v D:\MyWork\...\resources:/home/resources:rw -v D:\MyWork\...\logs:/home/logs:rw caesar-module-ai-openAi:1.0.0





